import { useModel } from "umi";
import compress from "gql-compress";

const useUpdateDepartment = () => {
    const { graphqlFetch } = useModel("global");

    const updateDepartment = async (variables) => {
        let res = await graphqlFetch({
            query: UpdateOrganizationInstitutionByOiUuid,
            variables,
        });
        return res ? true : false;
    };

    return { updateDepartment };
};

const UpdateOrganizationInstitutionByOiUuid = compress(`mutation MyMutation(
    $oiUuid: UUID!,
    $oiName: String!,
    $oiDesc: String,
    $maInfo: JSON,
    $upInfo: JSON!,
    $pyName: String!
) {
    updateOrganizationInstitutionByOiUuid(
        input: {
            oiUuid: $oiUuid
            organizationInstitutionPatch: {
                oiName: $oiName,
                oiDesc: $oiDesc,
                maInfo: $maInfo,
                upInfo: $upInfo,
                pyName: $pyName
            }
        }
    ) {
        clientMutationId
    }
}`);

export default useUpdateDepartment;
